package com.lb.jwitter.action;


 import java.util.ArrayList;
 import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import java.util.Collection;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import com.opensymphony.xwork2.Action; 
 import com.lb.jwitter.service.ConditionReport; 
 import com.lb.jwitter.service.TblQLDTTXAHocVien;
 import com.lb.jwitter.service.TblQLDTTXAHocVienService;
 import com.lb.jwitter.service.TblQLDTTXALop;
 import com.lb.jwitter.service.TblQLDTTXALopService;

import com.lb.jwitter.service.TblQLDTTXADMNganh;
 import com.lb.jwitter.service.TblQLDTTXADMNganhService;

import com.lb.jwitter.service.TblQLDTTXADMKhoa;
 import com.lb.jwitter.service.TblQLDTTXADMKhoaService;

import com.lb.jwitter.service.TblQLDTTXADMKhoaHoc;
 import com.lb.jwitter.service.TblQLDTTXADMKhoaHocService;

import com.lb.jwitter.service.TblQLDTTXADMChiNhanh;
 import com.lb.jwitter.service.TblQLDTTXADMChiNhanhService;

import com.lb.jwitter.service.TblQLDTTXAHoSoXetTuyen;
 import com.lb.jwitter.service.TblQLDTTXAHoSoXetTuyenService;

import com.lb.jwitter.service.TblQLDTTXADMTrangThaiHocVien;
 import com.lb.jwitter.service.TblQLDTTXADMTrangThaiHocVienService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAHocVienFormAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    private int page; 
    public int getPage() { return page; }

    public void setPage(int page) { this.page = page; }

    private int pages; 
    public int getPages() { return pages; }

    public void setPages(int pages) { this.pages = pages; }

    private String dataString; 
    public String getDataString() { return dataString; }

    private Collection<TblQLDTTXAHocVien> tblQLDTTXAHocViens; 
    public Collection<TblQLDTTXAHocVien>  getTblQLDTTXAHocViens() {
         return tblQLDTTXAHocViens; 
      } 

    private TblQLDTTXAHocVienService tblQLDTTXAHocVienService; 

    private Collection<TblQLDTTXALop> tblQLDTTXALops; 
    public Collection<TblQLDTTXALop>  getTblQLDTTXALops(){ 
              return tblQLDTTXALops; 
     } 

    private TblQLDTTXALopService tblQLDTTXALopService; 

    private Collection<TblQLDTTXADMNganh> tblQLDTTXADMNganhs; 
    public Collection<TblQLDTTXADMNganh>  getTblQLDTTXADMNganhs(){ 
              return tblQLDTTXADMNganhs; 
     } 

    private TblQLDTTXADMNganhService tblQLDTTXADMNganhService; 

    private Collection<TblQLDTTXADMKhoa> tblQLDTTXADMKhoas; 
    public Collection<TblQLDTTXADMKhoa>  getTblQLDTTXADMKhoas(){ 
              return tblQLDTTXADMKhoas; 
     } 

    private TblQLDTTXADMKhoaService tblQLDTTXADMKhoaService; 

    private Collection<TblQLDTTXADMKhoaHoc> tblQLDTTXADMKhoaHocs; 
    public Collection<TblQLDTTXADMKhoaHoc>  getTblQLDTTXADMKhoaHocs(){ 
              return tblQLDTTXADMKhoaHocs; 
     } 

    private TblQLDTTXADMKhoaHocService tblQLDTTXADMKhoaHocService; 

    private Collection<TblQLDTTXADMChiNhanh> tblQLDTTXADMChiNhanhs; 
    public Collection<TblQLDTTXADMChiNhanh>  getTblQLDTTXADMChiNhanhs(){ 
              return tblQLDTTXADMChiNhanhs; 
     } 

    private TblQLDTTXADMChiNhanhService tblQLDTTXADMChiNhanhService; 

    private Collection<TblQLDTTXAHoSoXetTuyen> tblQLDTTXAHoSoXetTuyens; 
    public Collection<TblQLDTTXAHoSoXetTuyen>  getTblQLDTTXAHoSoXetTuyens(){ 
              return tblQLDTTXAHoSoXetTuyens; 
     } 

    private TblQLDTTXAHoSoXetTuyenService tblQLDTTXAHoSoXetTuyenService; 

    private Collection<TblQLDTTXADMTrangThaiHocVien> tblQLDTTXADMTrangThaiHocViens; 
    public Collection<TblQLDTTXADMTrangThaiHocVien>  getTblQLDTTXADMTrangThaiHocViens(){ 
              return tblQLDTTXADMTrangThaiHocViens; 
     } 

    private TblQLDTTXADMTrangThaiHocVienService tblQLDTTXADMTrangThaiHocVienService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
    { 
        try{ 
      Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_HocVien", "xem")){ 
        return "noprivilege"; 
    }
tblQLDTTXAHocVienService = (TblQLDTTXAHocVienService) context.getBean("tbl_QLDTTXA_HocVienClient"); 
         tblQLDTTXALopService = (TblQLDTTXALopService) context.getBean("tbl_QLDTTXA_LopClient"); 

        tblQLDTTXADMNganhService = (TblQLDTTXADMNganhService) context.getBean("tbl_QLDTTXA_DM_NganhClient"); 

        tblQLDTTXADMKhoaService = (TblQLDTTXADMKhoaService) context.getBean("tbl_QLDTTXA_DM_KhoaClient"); 

        tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient"); 

        tblQLDTTXADMChiNhanhService = (TblQLDTTXADMChiNhanhService) context.getBean("tbl_QLDTTXA_DM_ChiNhanhClient"); 

        tblQLDTTXAHoSoXetTuyenService = (TblQLDTTXAHoSoXetTuyenService) context.getBean("tbl_QLDTTXA_HoSoXetTuyenClient"); 

        tblQLDTTXADMTrangThaiHocVienService = (TblQLDTTXADMTrangThaiHocVienService) context.getBean("tbl_QLDTTXA_DM_TrangThaiHocVienClient"); 

       if(pageSize == 0){ 
            pageSize = 20; 
        } 
        if(page == 0){ 
            page =1; 
        } 
        tblQLDTTXAHocViens =        tblQLDTTXAHocVienService.findAlltblQLDTTXAHocVien(pageSize, page); 
        pages = tblQLDTTXAHocVienService.counttblQLDTTXAHocVienByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      
      tblQLDTTXALops = tblQLDTTXALopService.findAlltblQLDTTXALop(0, 0);
      tblQLDTTXADMNganhs = tblQLDTTXADMNganhService.findAlltblQLDTTXADMNganh(0, 0);
      tblQLDTTXADMKhoas = tblQLDTTXADMKhoaService.findAlltblQLDTTXADMKhoa(0, 0);
      tblQLDTTXADMKhoaHocs = tblQLDTTXADMKhoaHocService.findAlltblQLDTTXADMKhoaHoc(0, 0);
      

      tblQLDTTXADMChiNhanhs = tblQLDTTXADMChiNhanhService.findAlltblQLDTTXADMChiNhanh(0, 0);

//      tblQLDTTXAHoSoXetTuyens = tblQLDTTXAHoSoXetTuyenService.findAlltblQLDTTXAHoSoXetTuyen(0, 0);
//      tblQLDTTXADMTrangThaiHocViens = tblQLDTTXADMTrangThaiHocVienService.findAlltblQLDTTXADMTrangThaiHocVien(0, 0);
      
      dataString = ""; 
      dataString += "&mSHV="; 
      dataString += "&hoTen="; 
      dataString += "&ten="; 
      dataString += "&lopId=" ; 
      dataString += "&nganhId=" ; 
      dataString += "&khoaId=" ; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi Form tbl_QLDTTXA_HocVien Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
